Obtain Serial Value

Obtain Serial Value

am 08.02.2006 15:03:02 von sistemascmp

This is a multi-part message in MIME format.

------=_NextPart_000_0053_01C62C9F.3AFAE060
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am using VB6+ADO+ODBC with pgSQL.
I need to obtain the value of a serial field (autogenerated) inmediatly =
after I do a INSERT query. How can I do?
------=_NextPart_000_0053_01C62C9F.3AFAE060
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">




I am using VB6+ADO+ODBC with =
pgSQL.

I need to obtain the value of a serial =
field=20
(autogenerated) inmediatly after I do a INSERT query.  How can I=20
do?


------=_NextPart_000_0053_01C62C9F.3AFAE060--

Re: Obtain Serial Value

am 08.02.2006 15:32:05 von Timothy Reed

------=_Part_2375_13317278.1139409125598
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

You should try SELECT MAX( ) FROM ; ??

On 2/8/06, Sistemas C.M.P. wrote:
>
> I am using VB6+ADO+ODBC with pgSQL.
> I need to obtain the value of a serial field (autogenerated) inmediatly
> after I do a INSERT query. How can I do?
>



--
--------
Timothy Reed

tareed@gmail.com

------=_Part_2375_13317278.1139409125598
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

You should try SELECT MAX( <fieldname> ) FROM <tablename>; ?? r>

On 2/8/06, ame">Sistemas C.M.P. < >sistemascmp@redynet4.com.ar
> wrote:
t: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1=
ex;">






I am using VB6+ADO+ODBC with pgSQL. ont>

I need to obtain the value of a serial=
field=20
(autogenerated) inmediatly after I do a INSERT query.  How can I=20
do?





--
--------
Timothy Ree=
d




------=_Part_2375_13317278.1139409125598--

Re: Obtain Serial Value

am 08.02.2006 15:46:50 von Ben.Trewern

This is a multi-part message in MIME format.

------_=_NextPart_001_01C62CBE.7E66134D
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Try using SELECT currval('sequenc_name');
=20
From the docs:
=20
Return the value most recently obtained by nextval for this sequence in
the current session. (An error is reported if nextval has never been
called for this sequence in this session.) Notice that because this is
returning a session-local value, it gives a predictable answer whether
or not other sessions have executed nextval since the current session
did.
=20
This should be much faster than SELECT max(... and transaction safe.
=20
Regards,

Ben

-----Original Message-----
From: pgsql-odbc-owner@postgresql.org
[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Timothy Reed
Sent: 08 February 2006 14:32
To: Sistemas C.M.P.
Cc: pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Obtain Serial Value
=09
=09
You should try SELECT MAX( ) FROM ; ??
=09
=09
On 2/8/06, Sistemas C.M.P. wrote:


I am using VB6+ADO+ODBC with pgSQL.
I need to obtain the value of a serial field
(autogenerated) inmediatly after I do a INSERT query. How can I do?




--=20
--------
Timothy Reed
=09
tareed@gmail.com
=09


------------------------------------------------------------ -------
This email and any attachments transmitted with it are confidential (and po=
tentially legally privileged) and intended solely for the use of the indivi=
dual or entity to whom they are addressed. If you have received this email =
in error please notify the sender and do not store, copy or disclose the co=
ntent to any other person.
It is the responsibility of the recipient to ensure that opening this messa=
ge and/or any of its attachments will not adversely affect its systems. No =
responsibility is accepted by the sender.
------------------------------------------------------------ -------



------_=_NextPart_001_01C62CBE.7E66134D
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Message




0ff> size=3D2>Try using SELECT  N=20
class=3D293154214-08022006>currval
('sequenc_name'); ONT>

size=3D2> 

ze=3D2>From=20
the docs:

size=3D2> 

Return the value most recently obtain=
ed by=20
nextval for this sequence in the current sess=
ion.=20
(An error is reported if nextval has never be=
en=20
called for this sequence in this session.) Notice that because this is retu=
rning=20
a session-local value, it gives a predictable answer whether or not other=
=20
sessions have executed nextval since the curr=
ent=20
session did.

 

022006>This=20
should be much faster than SELECT max(... and transaction=20
safe.

 

size=3D2>Regards,

Ben


style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px soli=
d; MARGIN-RIGHT: 0px">

NT=20
face=3DTahoma size=3D2>-----Original Message-----
From:=20
pgsql-odbc-owner@postgresql.org [mailto:pgsql-odbc-owner@postgresql.org] =
On=20
Behalf Of
Timothy Reed
Sent: 08 February 2006=20
14:32
To: Sistemas C.M.P.
Cc:=20
pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Obtain Serial=20
Value

You should try SELECT MAX( <fieldname> ) =
FROM=20
<tablename>; ??


On 2/8/06, Sis=
temas=20
C.M.P.
< href=3D"mailto:sistemascmp@redynet4.com.ar">sistemascmp@redy net4.com.ar <=
/A>>=20
wrote:

style=3D"PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(2=
04,204,204) 1px solid">
I am using VB6+ADO+ODBC with=20
pgSQL.

I need to obtain the value of a serial=
field=20
(autogenerated) inmediatly after I do a INSERT query.  How can I=
=20
do?



--=20

--------
Timothy Reed

href=3D"mailto:tareed@gmail.com">tareed@gmail.com

-------------------=
------------------------------------------------


This email and any =
attachments transmitted with it are confidential (and potentially legally p=
rivileged) and intended solely for the use of the individual or entity to w=
hom they are addressed. If you have received this email in error please not=
ify the sender and do not store, copy or disclose the content to any other =
person.


It is the responsib=
ility of the recipient to ensure that opening this message and/or any of it=
s attachments will not adversely affect its systems. No responsibility is a=
ccepted by the sender.


-------------------=
------------------------------------------------



 


 

BODY>

------_=_NextPart_001_01C62CBE.7E66134D--

Antw: Obtain Serial Value

am 08.02.2006 17:37:40 von Thomas Holschen

... or use a "stored procedure" aka function...


CREATE OR REPLACE FUNCTION hela_add_programm(pm_programmname
"varchar")
RETURNS int4 AS
$BODY$ declare NewProgrammID integer;
Begin
select into NewProgrammID nextval('programm_idprogramm_seq');
Insert Into programm(idprogramm,programmname) values
(NewProgrammID,pm_Programmname);
Return NewProgrammID;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
--=20

_____________________________________________
Hela Gewürzwerk Hermann Laue GmbH & Co.KG
EDV
Thomas Holschen=20
Beimoorweg 11
22926 Ahrensburg

Tel. : +49 4102/496-381
http://www.hela-food.de=20
_____________________________________________

>>> "Sistemas C.M.P." schrieb am
Mittwoch, 8. Februar
2006 um 15:03 in Nachricht
<005601c62cb8$606b57d0$1601a8c0@pcsistemas>:
> I am using VB6+ADO+ODBC with pgSQL.
> I need to obtain the value of a serial field (autogenerated)
inmediatly=20
> after I do a INSERT query. How can I do?
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informa=
tionen. Wenn=20
Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalte=
n haben,=20
informieren Sie bitte den Absender und löschen Sie diese E-Mail. Das uner=
laubte=20
Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet. =
Aus=20
Rechts- und Sicherheitsgründen ist die in dieser E-Mail gegebene Informat=
ion nicht=20
rechtsverbindlich.

This e-mail contains confidential and/or privileged information. If you are=
not the=20
intended addressee or have received this e-mail in error please notify the =
sender and=20
delete this e-mail. Any unauthorized copying, disclosure or distribution of=
the material=20
in this e-mail is strictly forbidden. Due to legal and security reasons the=
information=20
contained in this e-mail is not legally binding.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org